#ifndef __ENTITY_H__
#define __ENTITY_H__

#include <nds.h>
#include "vec.h"

class Entity {
 public:
  float x;
  float y;
  int health;
  bool gotHit;
  int stepped;
  
 protected:
  u16* mainGfx;
  u16* subGfx;
  int palette;
  int num;
  Vec vel;
  Vec accel;

 public:
  static int count;
  static int paletteCount;
  Entity(int x, int y, int palette, u16* main, u16* sub);
  void move(int x, int y);
  void step();
  void getHit(int laserPower);
  float collisionTime(int rayx, int rayy, float dirx, float diry);
  void takeThisGiftSoThatYouMayLiiiive(int playerKills);
  void killThoseWhoWanderAstray();
  virtual int reflectAngle(int impactX, int impactY,
			   float dirx, float diry,
			   int* reflections) = 0;

  static int initGfx(const void* palette, int palLen,
                     const void* tiles, int len,
                     u16** main, u16** sub);
  void animate_stepright();
  void animate_stepleft();
};

class ReflectiveEntity : public Entity {
public:
  ReflectiveEntity(int xx, int yy, int p, u16* main, u16* sub)
    : Entity(xx, yy, p, main, sub) { }
  int reflectAngle(int impactX, int impactY,
		   float dirx, float diry,
		   int* reflections);
};

class RedirectEntity : public Entity {
public:
  RedirectEntity(int xx, int yy, int p, u16* main, u16* sub)
    : Entity(xx, yy, p, main, sub) { }
  int reflectAngle(int impactX, int impactY,
		   float dirx, float diry,
		   int* reflections);
};

class BoringEntity : public Entity {
public:
  BoringEntity(int xx, int yy, int p, u16* main, u16* sub)
    : Entity(xx, yy, p, main, sub) { }
  int reflectAngle(int impactX, int impactY,
		   float dirx, float diry,
		   int* reflections);
};

class SplitterEntity : public Entity {
public:
  SplitterEntity(int xx, int yy, int p, u16* main, u16* sub)
    : Entity(xx, yy, p, main, sub) { }
  int reflectAngle(int impactX, int impactY,
		   float dirx, float diry,
		   int* reflections);
};

#endif
